<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加分类</title>
    <link rel="shortcut icon" href="favicon.ico">

    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" th:href="@{/resource/css/bootstrap.min.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/font-awesome.min.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/animate.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/style.css}" />
    <link rel="stylesheet" th:href="@{/resource/css/plugins/toastr/toastr.min.css}" />
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加分类</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" method="post">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-8">
                                <input id="name" type="text" class="form-control" name="name" required="" aria-required="true">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="flag" id="flag">
                                    <option value="0">正常</option>
                                    <option value="1">停用</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否默认：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="def" id="def">
                                    <option value="1">默认</option>
                                    <option value="0">可选</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否可删：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="isdel" id="isdel">
                                    <option value="0">可删</option>
                                    <option value="1">不可删</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input id="orderno" type="text" class="form-control" name="orderno" required="" aria-required="true">
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" id="category_submit" type="button">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>

    </div>

</div>



<script type="text/javascript" th:src="@{/script/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/bootstrap.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js}"></script>
<script th:src="@{/script/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/contabs.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/toastr/toastr.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/common/common.js}"></script>
<script type="text/javascript" th:src="@{/script/js/common/menu/menu.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/validate/messages_zh.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/plugins/validate/jquery.validate.min.js}"></script>
<script type="text/javascript" th:src="@{/script/js/demo/form-validate-demo.js}"></script>
<script>

    $("#category_submit").click(function () {
        var cid = $("#cid").val();
        var name = $("#name").val();
        var def = $("#def").val();
        var isdel = $("#isdel").val();
        var flag = $("#flag").val();
        var orderno = $("#orderno").val();
        if(name==""||orderno==""){
            toastr.error("请补全信息!");
            return;
        }
        var mydata = '{"cid":"'  + cid + '","name":"'  + name + '","def":"'+def+'","isdel":"'+isdel+'","flag":"'+flag+'","flag":"'+flag+'","orderno":"'+orderno+'"}';
        $.ajax({
            url: "/common/category/updateCategory",
            type: "post",
            data: mydata,
            contentType: "application/json",
            dataType:"json",
            success: function (data) {
                if(data["retType"] == "0") {
                    toastr.success("修改成功!");
                    setTimeout( "window.location.href='/common/category/doCategoryList'",1000);//延时3秒

                } else {
                    toastr.error(data["retMsg"]);
                }
            }
        });
    });
</script>

</body>

</html>